package com.itWaiLong.Controller.Improve;

import com.itWaiLong.Dao.personal_info;
import com.itWaiLong.Result.Result;
import com.itWaiLong.ReturnString.ResponseData;
import com.itWaiLong.Service.ImproveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/improve")
public class ImproveController {

    @Autowired
    private ImproveService improveService;

    /**
     * 完善个人信息
     * @param personal_info 用户的详细信息
     * @return 返回完善状态
     */
    @PostMapping("/improveUserInfo")
    public Result ImproveUserInfo(@RequestBody personal_info personal_info) {
        int result = improveService.ImproveUserInfo(personal_info);

        if (result == -1) {
            return Result.fail(ResponseData.YONG_HU_YI_JIN_WAN_SHAN);
        }

        if (result > 0) {
            return Result.success(ResponseData.WAN_SAN_CHENG_GONG);
        }
        return Result.fail(ResponseData.WAN_SAN_SHI_BAI);
    }


    /**
     * 编辑完善的信息
     * @param personal_info 编辑所需的数据
     * @return 返回编辑状态
     */
    @PostMapping("/updateImproveInfo")
    public Result updateImproveInfo(@RequestBody personal_info personal_info) {
        int result = improveService.updateImproveInfo(personal_info);
        if (result > 0){
            return Result.success(ResponseData.BIA_JI_CHEN_GONG);
        }
        return Result.fail(ResponseData.BIA_JI_SHI_BAI);
    }
}
